package com.koron.css2.baseConfig.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.baseConfig.bean.WaterChargeElfBean;
import com.koron.css2.baseConfig.mapper.WaterChargeElfMapper;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.util.Constant;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;


/**
 * 水费账单精灵-列表
 *
 * @author 廖大富
 */
public class WaterChargeElfList implements ServerInterface {
    private static Logger logger = LogManager.getLogger(WaterChargeElfList.class);

    @Override
    public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
        @SuppressWarnings("rawtypes")
        MessageBean<WaterChargeElfBean> info = MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "success", WaterChargeElfBean.class);
        try {
            WaterChargeElfMapper mapper = factory.getMapper(WaterChargeElfMapper.class);
            WaterChargeElfBean waterChargeElfBean = mapper.selectWaterChargeElf();
            info.setCode(Constant.MESSAGE_INT_SUCCESS);
            info.setDescription("success");
            info.setData(waterChargeElfBean);
        } catch (Exception e) {
            info.setCode(Constant.MESSAGE_INT_FAIL);
            info.setDescription("操作失败");
            logger.error("操作失败", e);
        }
        return info;
    }
}
